package cn.tianyigps.tianyigpsapiv2.param.vo;

import cn.tianyigps.tianyigpsapiv2.param.enums.ResponseEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: LiuHao
 * @Descirption:
 * @Date: 2019/4/3_21:43
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseVo {

    private int code;

    private boolean success;

    private String msg;

    private Object content;

    public static ResponseVo response(ResponseEnum responseEnum){
        return new ResponseVo(responseEnum.getCode(),responseEnum.getSuccess(),responseEnum.getMsg(),null);
    }

    public static ResponseVo response(ResponseEnum responseEnum,Object content){
        return new ResponseVo(responseEnum.getCode(),responseEnum.getSuccess(),responseEnum.getMsg(),content);
    }

    public static ResponseVo success(){
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(200);
        responseVo.setMsg("成功");
        responseVo.setSuccess(true);
        return responseVo;
    }

    public static ResponseVo success(String msg){
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(200);
        responseVo.setMsg(msg);
        responseVo.setSuccess(true);
        return responseVo;
    }

    public static ResponseVo success(String msg, Object t){
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(200);
        responseVo.setMsg(msg);
        responseVo.setSuccess(true);
        responseVo.setContent(t);
        return responseVo;
    }

    public static ResponseVo badRequest(String msg){
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(400);
        responseVo.setMsg(msg);
        responseVo.setSuccess(false);
        return responseVo;
    }

    public static ResponseVo notFoundRequest(String msg){
        ResponseVo responseVo = new ResponseVo();
        responseVo.setCode(404);
        responseVo.setMsg(msg);
        responseVo.setSuccess(false);
        return responseVo;
    }
}
